{% set page_title = _("Overview") %}

{% extends theme("management/management_layout.html") %}

{% block breadcrumb %}
<ol class="breadcrumb flaskbb-breadcrumb">
    <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
    <li class="active">{% trans %}Management{% endtrans %}</li>
</ol>
{% endblock %}

{% block management_content %}
<div class="col-md-12 settings-col">
    <div class="panel settings-panel">
        <div class="panel-heading settings-head">
            <span class="fa fa-tasks"></span> {% trans %}Overview{% endtrans %}
        </div>
        <div class="panel-body settings-body">
            <div class="settings-content">
                <div class="stats">
                    <div class="row stats-row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            {# TODO: I have a feeling that this can be done so much nicer #}
                            {% if not celery_running %}
                            <div class="alert-message alert-message-danger">
                                <h4>{% trans %}There is a problem.{% endtrans %}</h4>
                                <p>{% trans %}Celery is <strong>not</strong> running.{% endtrans %}</p>
                                <p>{% trans %}You can start celery with this command:{% endtrans %}</p>
                                <pre>flaskbb --config {{ current_app.config["CONFIG_PATH"] }} celery worker</pre>
                            </div>
                            {% elif unread_reports > 0 %}
                            <div class="alert-message alert-message-warning">
                                <h4>{% trans %}There is something that wants your attention.{% endtrans %}</h4>
                                <p>{% trans url=url_for('management.unread_reports') %}You have <a href="{{ url }}">{{ unread_reports }} unread reports</a>.{% endtrans %}</p>
                            </div>
                            {% else %}
                            <div class="alert-message alert-message-success">
                                <h4>{% trans %}Everything seems alright.{% endtrans %}</h4>
                                <p>{% trans %}No new notifications.{% endtrans %}</p>
                            </div>
                            {% endif %}
                        </div>
                    </div>
                    <div class="row stats-row">
                        <div class="col-md-4 col-sm-4 col-xs-4">
                            <div class="stats-widget">
                                <div class="icon">
                                     <i class="fa fa-users text-success"></i>
                                </div>
                                <div class="text">
                                    <var>{{ all_users }}</var>
                                    <label class="text-muted">{% trans %}users{% endtrans %}</label>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-4 col-sm-4 col-xs-4">
                            <div class="stats-widget">
                                <div class="icon">
                                     <i class="fa fa-comment text-primary"></i>
                                </div>
                                <div class="text">
                                    <var>{{ post_count }}</var>
                                    <label class="text-muted">{% trans %}posts{% endtrans %}</label>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-4 col-sm-4 col-xs-4">
                            <div class="stats-widget">
                                <div class="icon">
                                     <i class="fa fa-comments text-info"></i>
                                </div>
                                <div class="text">
                                    <var>{{ topic_count }}</var>
                                    <label class="text-muted">{% trans %}topics{% endtrans %}</label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row stats-row">

                        <div class="col-md-4 col-sm-4 col-xs-4">
                            <div class="row stats-heading">{% trans %}Statistics{% endtrans %}</div>

                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Registered users{% endtrans %}</div><div class="value pull-right">{{ all_users }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Online users{% endtrans %}</div><div class="value pull-right">{{ online_users }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Banned users{% endtrans %}</div><div class="value pull-right">{{ banned_users }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Groups{% endtrans %}</div><div class="value pull-right">{{ all_groups }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Topics{% endtrans %}</div><div class="value pull-right">{{ topic_count }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Posts{% endtrans %}</div><div class="value pull-right">{{ post_count }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">{% trans %}Reports{% endtrans %}</div><div class="value pull-right">{{ report_count }}</div>
                            </div>
                        </div>

                        <div class="col-md-4 col-sm-4 col-xs-4">
                            <div class="row stats-heading">{% trans %}Components{% endtrans %}</div>

                            <div class="row stats-item">
                                <div class="key pull-left">FlaskBB</div><div class="value pull-right">{{ flaskbb_version }}</div>
                            </div>
                            <!--  TODO: Implement a API. one day..
                            <div class="row stats-item">
                                <div class="key pull-left">FlaskBB API</div><div class="value pull-right">v1</div>
                            </div>
                            -->
                            <div class="row stats-item">
                                <div class="key pull-left">Celery</div><div class="value pull-right">
                                {% if celery_running %}
                                    <span class="text-success"><strong>running</strong></span>
                                {% else %}
                                <span class="text-danger"><strong>not running</strong></span>
                                {% endif %}
                                {{ celery_version }}
                                </div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">Flask</div><div class="value pull-right">{{ flask_version }}</div>
                            </div>
                            <div class="row stats-item">
                                <div class="key pull-left">Python</div><div class="value pull-right">{{ python_version }}</div>
                            </div>
                        </div>

                        <div class="col-md-4 col-sm-4 col-xs-4">
                            <div class="row stats-heading">{% trans %}Plugins{% endtrans %}</div>

                            {% for plugin in plugins %}
                            <div class="row stats-item">
                                <div class="key pull-left">
                                {% if plugin.installed %}
                                    <a href="{{ url_for('management.settings', slug=plugin.settings_key) }}">{{ plugin.name }}</a>
                                {% else %}
                                    <a href="{{ url_for('management.plugins') }}">{{ plugin.name }}</a>
                                {% endif %}
                                </div>
                                <div class="value pull-right">
                                    {% if not plugin.enabled %}
                                        <span class="text-danger">not enabled</span>
                                    {% elif plugin.enabled and plugin.installed %}
                                        <span class="text-success">enabled &amp; installed</span>
                                    {% elif plugin.enabled and not plugin.installed %}
                                        <span class="text-warning">not installed</span>
                                    {% endif %}
                                    {{ plugin.version }}
                                </div>
                            </div>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
